<template>
  <div>
    <!--  面包屑导航   -->
    <el-breadcrumb>
      <el-breadcrumb-item :to="{path:'/home'}">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!--  卡片区域  -->
    <el-card>
      <el-row>
        <el-col :span="8">
          <el-input placeholder="请输入内容" v-model="queryInfo.query" class="input-with-select">
            <el-button slot="append" @click="getOrderList" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!--  订单数据列表    -->
      <el-table :data="orderList" stripe border>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="order_number" label="订单编号"></el-table-column>
        <el-table-column prop="order_price" label="订单价格"></el-table-column>
        <el-table-column prop="pay_status" label="是否付款">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.pay_status === '1'">已付款</el-tag>
            <el-tag type="danger" v-else>未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货"></el-table-column>
        <el-table-column prop="create_time" label="下单时间">
          <template slot-scope="scope">
            {{scope.row.create_time | timeFilter}}
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template>
            <el-button size="mini" type="primary" @click="editAddress" icon="el-icon-edit"></el-button>
            <el-button size="mini" type="success" @click="progress" icon="el-icon-setting"></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--  分页器   -->
      <el-pagination :total="total" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
                     @current-change="handleCurrentChange" :current-page="queryInfo.pagenum"
                     :page-size="queryInfo.pagesize" :page-sizes="[10,20,30,40]"></el-pagination>
    </el-card>
    <!--  编辑对话框   -->
    <el-dialog style="text-align: left" title="修改地址" :visible.sync="editDialogVisible">
      <el-form>
        <el-form-item label="省市区/县：">
          <el-cascader></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址：">
          <el-input type="text"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
    <!--  物流跟进对话框 -->
    <el-dialog title="物流跟进" :visible.sync="dialogVisible"></el-dialog>
  </div>
</template>

<script>
  export default {
    name: "Order",
    data() {
      return {
        editDialogVisible: false,
        dialogVisible:false,
        queryInfo: {
          query: '',
          pagenum: 1,
          pagesize: 10
        },
        orderList: [],
        total: 20,
      }
    },

    created() {
      this.getOrderList()
    },

    methods: {
      /*  监听物流进度  */
      progress(){
        this.dialogVisible = true;
      },
      /*  监听修改地址  */
      editAddress() {
        this.editDialogVisible = true;
      },
      /*  箭头每页多少条数据   */
      handleSizeChange(pageSize) {
        this.queryInfo.pagesize = pageSize;
        this.getOrderList();
      },
      /*  监听当前页码  */
      handleCurrentChange(currentNum) {
        this.queryInfo.pagenum = currentNum;
        this.getOrderList();
      },
      /*  获取订单列表数据  */
      async getOrderList() {
        const {data: res} = await this.$http.get('orders', {params: this.queryInfo});
        if (res.meta.status === 200) {
          this.orderList = res.data.goods;
          this.total = res.data.total;
        } else {
          this.$message.error('获取订单列表数据失败');
        }
      }
    }
  }
</script>

<style scoped>
  .el-form-item{
    text-align: left;
  }

  .el-input {
    width: 305px;
  }
</style>
